diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-04-24 03:48:09 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-04-24 03:48:09 +0000 |
commit | 52fbbb16a14e2417d7bb807e36547d2b5afbde43 (patch) | |
tree | 72b305c9d5a2e88ca541ec8f5a91c1fe8947c1eb /clang/unittests/Tooling | |
parent | 1f29ccf3fba58ba99731084948316d9f160c0735 (diff) | |
download | bcm5719-llvm-52fbbb16a14e2417d7bb807e36547d2b5afbde43.tar.gz bcm5719-llvm-52fbbb16a14e2417d7bb807e36547d2b5afbde43.zip |
Fix four more test-only leaks found by LSan.
Tool::run() doesn't take ownership of the passed action.
llvm-svn: 207071
Diffstat (limited to 'clang/unittests/Tooling')
-rw-r--r-- | clang/unittests/Tooling/ToolingTest.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/unittests/Tooling/ToolingTest.cpp b/clang/unittests/Tooling/ToolingTest.cpp index 1eff6d064fc..ebc647ddade 100644 --- a/clang/unittests/Tooling/ToolingTest.cpp +++ b/clang/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<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); } |