r207071 - Fix four more test-only leaks found by LSan.
Nico Weber
nicolasweber at gmx.de
Wed Apr 23 20:48:09 PDT 2014
Author: nico
Date: Wed Apr 23 22:48:09 2014
New Revision: 207071
URL: http://llvm.org/viewvc/llvm-project?rev=207071&view=rev
Log:
Fix four more test-only leaks found by LSan.
Tool::run() doesn't take ownership of the passed action.
Modified:
cfe/trunk/unittests/Tooling/ToolingTest.cpp
Modified: cfe/trunk/unittests/Tooling/ToolingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/ToolingTest.cpp?rev=207071&r1=207070&r2=207071&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/ToolingTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/ToolingTest.cpp Wed Apr 23 22:48:09 2014
@@ -206,7 +206,9 @@ TEST(newFrontendActionFactory, InjectsSo
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, InjectDiagnosticCons
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);
}
More information about the cfe-commits
mailing list